| Fully Qualified Name: | CodeIgniter\Database\SQLite3\Connection |
| Extends: | BaseConnection |
| Implements: | ConnectionInterface |
Connection for SQLite3
| Name | Description | Defined By |
|---|---|---|
| __construct() | Saves our connection settings. | BaseConnection |
| __get() | Accessor for properties if they exist. | BaseConnection |
| __isset() | Checker for properties existence. | BaseConnection |
| _fieldData() | Returns an array of objects with field data | Connection |
| _foreignKeyData() | Returns an array of objects with Foreign key data | Connection |
| _indexData() | Returns an array of objects with index data | Connection |
| addTableAlias() | Add a table alias to our list. | BaseConnection |
| affectedRows() | Returns the total number of rows affected by this query. | Connection |
| callFunction() | This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner. | BaseConnection |
| close() | Close the database connection. | BaseConnection |
| connect() | Connect to the database. | Connection |
| disableForeignKeyChecks() | Disables foreign key checks temporarily. | BaseConnection |
| enableForeignKeyChecks() | Enables foreign key checks temporarily. | BaseConnection |
| error() | Returns the last error code and message. | Connection |
| escape() | "Smart" Escape String | BaseConnection |
| escapeIdentifiers() | Escape the SQL Identifiers | BaseConnection |
| escapeLikeString() | Escape LIKE String | BaseConnection |
| escapeString() | Escape String | BaseConnection |
| execute() | Execute the query | Connection |
| fieldExists() | Determine if a particular field exists | BaseConnection |
| getConnectDuration() | Returns the number of seconds with microseconds that it took to connect to the database. | BaseConnection |
| getConnectStart() | Returns the time we started to connect to this database in seconds with microseconds. | BaseConnection |
| getConnection() | Returns the actual connection object. If both a 'read' and 'write' connection has been specified, you can pass either term in to get that connection. If you pass either alias in and only a single connection is present, it must return the sole connection. | BaseConnection |
| getDatabase() | Returns the name of the current database being used. | BaseConnection |
| getError() | Returns the last error encountered by this connection. | BaseConnection |
| getFieldData() | Returns an object with field data | BaseConnection |
| getFieldNames() | Fetch Field Names | Connection |
| getForeignKeyData() | Returns an object with foreign key data | BaseConnection |
| getIndexData() | Returns an object with key data | BaseConnection |
| getLastQuery() | Returns the last query's statement object. | BaseConnection |
| getPlatform() | The name of the platform in use (MySQLi, mssql, etc) | BaseConnection |
| getPrefix() | Returns the database prefix. | BaseConnection |
| getVersion() | Returns a string containing the version of the database being used. | Connection |
| initialize() | Initializes the database connection/settings. | BaseConnection |
| insertID() | Insert ID | Connection |
| isWriteType() | Determines if the statement is a write-type query or not. | Connection |
| listTables() | Returns an array of table names | BaseConnection |
| persistentConnect() | Create a persistent database connection. | BaseConnection |
| prefixTable() | DB Prefix | BaseConnection |
| prepare() | Creates a prepared statement with the database that can then be used to execute multiple statements against. Within the closure, you would build the query in any normal way, though the Query Builder is the expected manner. | BaseConnection |
| pretend() | Allows the engine to be set into a mode where queries are not actually executed, but they are still generated, timed, etc. | BaseConnection |
| protectIdentifiers() | Protect Identifiers | BaseConnection |
| query() | Orchestrates a query against the database. Queries must use Database\Statement objects to store the query and build it. | BaseConnection |
| reconnect() | Keep or establish the connection if no queries have been sent for a length of time exceeding the server's idle timeout. | Connection |
| resetDataCache() | Empties our data cache. Especially helpful during testing. | BaseConnection |
| setAliasedTables() | Sets the Table Aliases to use. These are typically collected during use of the Builder, and set here so queries are built correctly. | BaseConnection |
| setDatabase() | Select a specific database table to use. | Connection |
| setPrefix() | Set DB Prefix | BaseConnection |
| showLastQuery() | Returns a string representation of the last query's statement object. | BaseConnection |
| simpleQuery() | Performs a basic query against the database. No binding or caching is performed, nor are transactions handled. Simply takes a raw query string and returns the database-specific result id. | BaseConnection |
| supportsForeignKeys() | Checks to see if the current install supports Foreign Keys and has them enabled. | Connection |
| table() | Returns an instance of the query builder for this connection. | BaseConnection |
| tableExists() | Determine if a particular table exists | BaseConnection |
| transBegin() | Begin Transaction | BaseConnection |
| transCommit() | Commit Transaction | BaseConnection |
| transComplete() | Complete Transaction | BaseConnection |
| transOff() | Disable Transactions | BaseConnection |
| transRollback() | Rollback Transaction | BaseConnection |
| transStart() | Start Transaction | BaseConnection |
| transStatus() | Lets you retrieve the transaction flag to determine if it has failed | BaseConnection |
| transStrict() | Enable/disable Transaction Strict Mode | BaseConnection |
Saves our connection settings.
| Parameter Name | Type | Description |
|---|---|---|
| $params | array |
Returns:
Accessor for properties if they exist.
| Parameter Name | Type | Description |
|---|---|---|
| $key | string |
Returns: mixed
Checker for properties existence.
| Parameter Name | Type | Description |
|---|---|---|
| $key | string |
Returns: bool
Returns an array of objects with field data
| Parameter Name | Type | Description |
|---|---|---|
| $table | string |
Returns: \stdClass[]
Returns an array of objects with Foreign key data
| Parameter Name | Type | Description |
|---|---|---|
| $table | string |
Returns: \stdClass[]
Returns an array of objects with index data
| Parameter Name | Type | Description |
|---|---|---|
| $table | string |
Returns: \stdClass[]
Add a table alias to our list.
| Parameter Name | Type | Description |
|---|---|---|
| $table | string |
Returns: $this
Returns the total number of rows affected by this query.
Returns: int
This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner.
| Parameter Name | Type | Description |
|---|---|---|
| $functionName | string | |
| ...$params | array | |
| $params |
Returns: bool
Close the database connection.
Returns: void
Connect to the database.
| Parameter Name | Type | Description |
|---|---|---|
| $persistent | bool |
Returns: mixed
Disables foreign key checks temporarily.
Returns:
Enables foreign key checks temporarily.
Returns:
Returns the last error code and message.
Must return an array with keys 'code' and 'message':
return ['code' => null, 'message' => null);
Returns: array
"Smart" Escape String
Escapes data based on type. Sets boolean and null types
| Parameter Name | Type | Description |
|---|---|---|
| $str | mixed |
Returns: mixed
Escape the SQL Identifiers
This function escapes column and table names
| Parameter Name | Type | Description |
|---|---|---|
| $item | mixed |
Returns: mixed
Escape LIKE String
Calls the individual driver for platform specific escaping for LIKE conditions
| Parameter Name | Type | Description |
|---|---|---|
| $ | string|string[] | |
| $str |
Returns: string|string[]
Escape String
| Parameter Name | Type | Description |
|---|---|---|
| $str | string|string[] | Input |
| $like | bool | Whether |
Returns: string|string[]
Execute the query
| Parameter Name | Type | Description |
|---|---|---|
| $sql | string |
Returns: mixed \SQLite3Result object or bool
Determine if a particular field exists
| Parameter Name | Type | Description |
|---|---|---|
| $fieldName | string | |
| $tableName | string |
Returns: bool
Returns the number of seconds with microseconds that it took to connect to the database.
Used by the Debug Toolbar's timeline.
| Parameter Name | Type | Description |
|---|---|---|
| $decimals | int |
Returns: string
Returns the time we started to connect to this database in seconds with microseconds.
Used by the Debug Toolbar's timeline.
Returns: float|null
Returns the actual connection object. If both a 'read' and 'write' connection has been specified, you can pass either term in to get that connection. If you pass either alias in and only a single connection is present, it must return the sole connection.
| Parameter Name | Type | Description |
|---|---|---|
| $alias | string|null |
Returns: mixed
Returns the name of the current database being used.
Returns: string
Returns the last error encountered by this connection.
Returns: mixed
Returns an object with field data
| Parameter Name | Type | Description |
|---|---|---|
| $table | string | the |
Returns: array|bool
Fetch Field Names
| Parameter Name | Type | Description |
|---|---|---|
| $table | string | Table |
Returns: array|bool
Returns an object with foreign key data
| Parameter Name | Type | Description |
|---|---|---|
| $table | string | the |
Returns: array|bool
Returns an object with key data
| Parameter Name | Type | Description |
|---|---|---|
| $table | string | the |
Returns: array|bool
Returns the last query's statement object.
Returns: mixed
The name of the platform in use (MySQLi, mssql, etc)
Returns: string
Returns the database prefix.
Returns: string
Returns a string containing the version of the database being used.
Returns: string
Initializes the database connection/settings.
Returns: mixed|void
Insert ID
Returns: int
Determines if the statement is a write-type query or not.
| Parameter Name | Type | Description |
|---|---|---|
| $sql |
Returns: bool
Returns an array of table names
| Parameter Name | Type | Description |
|---|---|---|
| $constrainByPrefix | bool | = |
Returns: bool|array
Create a persistent database connection.
Returns: mixed
DB Prefix
Prepends a database prefix if one exists in configuration
| Parameter Name | Type | Description |
|---|---|---|
| $table | string | the |
Returns: string
Creates a prepared statement with the database that can then be used to execute multiple statements against. Within the closure, you would build the query in any normal way, though the Query Builder is the expected manner.
Example: $stmt = $db->prepare(function($db)
{
return $db->table('users')
->where('id', 1)
->get();
})
| Parameter Name | Type | Description |
|---|---|---|
| $func | \Closure | |
| $options | array | Passed |
Returns: \BasePreparedQuery|null
Allows the engine to be set into a mode where queries are not actually executed, but they are still generated, timed, etc.
This is primarily used by the prepared query functionality.
| Parameter Name | Type | Description |
|---|---|---|
| $pretend | bool |
Returns: $this
Protect Identifiers
This function is used extensively by the Query Builder class, and by a couple functions in this class. It takes a column or table name (optionally with an alias) and inserts the table prefix onto it. Some logic is necessary in order to deal with column names that include the path. Consider a query like this:
SELECT hostname.database.table.column AS c FROM hostname.database.table
Or a query with aliasing:
SELECT m.member_id, m.member_name FROM members AS m
Since the column name can include up to four segments (host, DB, table, column) or also have an alias prefix, we need to do a bit of work to figure this out and insert the table prefix (if it exists) in the proper position, and escape only the correct identifiers.
| Parameter Name | Type | Description |
|---|---|---|
| $item | string|array | |
| $prefixSingle | bool | |
| $protectIdentifiers | bool | |
| $fieldExists | bool |
Returns: string|array
Orchestrates a query against the database. Queries must use Database\Statement objects to store the query and build it.
This method works with the cache.
Should automatically handle different connections for read/write queries if needed.
| Parameter Name | Type | Description |
|---|---|---|
| $sql | string | |
| ...$binds | mixed | |
| $setEscapeFlags | bool | |
| $queryClass | string | |
| $binds |
Returns: \BaseResult|\Query|bool
Keep or establish the connection if no queries have been sent for a length of time exceeding the server's idle timeout.
Returns: void
Empties our data cache. Especially helpful during testing.
Returns: $this
Sets the Table Aliases to use. These are typically collected during use of the Builder, and set here so queries are built correctly.
| Parameter Name | Type | Description |
|---|---|---|
| $aliases | array |
Returns: $this
Select a specific database table to use.
| Parameter Name | Type | Description |
|---|---|---|
| $databaseName | string |
Returns: bool
Set DB Prefix
Set's the DB Prefix to something new without needing to reconnect
| Parameter Name | Type | Description |
|---|---|---|
| $prefix | string | The |
Returns: string
Returns a string representation of the last query's statement object.
Returns: string
Performs a basic query against the database. No binding or caching is performed, nor are transactions handled. Simply takes a raw query string and returns the database-specific result id.
| Parameter Name | Type | Description |
|---|---|---|
| $sql | string |
Returns: mixed
Checks to see if the current install supports Foreign Keys and has them enabled.
Returns: bool
Returns an instance of the query builder for this connection.
| Parameter Name | Type | Description |
|---|---|---|
| $tableName | string|array |
Returns: \BaseBuilder
Determine if a particular table exists
| Parameter Name | Type | Description |
|---|---|---|
| $tableName | string |
Returns: bool
Begin Transaction
| Parameter Name | Type | Description |
|---|---|---|
| $test_mode | bool |
Returns: bool
Commit Transaction
Returns: bool
Complete Transaction
Returns: bool
Disable Transactions
This permits transactions to be disabled at run-time.
Returns: void
Rollback Transaction
Returns: bool
Start Transaction
| Parameter Name | Type | Description |
|---|---|---|
| $test_mode | bool | = |
Returns: bool
Lets you retrieve the transaction flag to determine if it has failed
Returns: bool
Enable/disable Transaction Strict Mode
When strict mode is enabled, if you are running multiple groups of transactions, if one group fails all subsequent groups will be rolled back.
If strict mode is disabled, each group is treated autonomously, meaning a failure of one group will not affect any others
| Parameter Name | Type | Description |
|---|---|---|
| $mode | bool | = |
Returns: $this